package net.peihuan.service.impl;

import net.peihuan.dao.TagMapper;
import net.peihuan.entity.Tag;
import net.peihuan.service.TagService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
public class TagServiceImpl  implements TagService {


    @Resource
    private TagMapper tagMapper;


    @Override
    public List<Tag> findAllWithArticles() {
        return tagMapper.selectAllTagsWithArticle();
    }

    @Override
    public List<Tag> findAll() {
        return tagMapper.selectAllTags();
    }

    @Override
    public int save(Tag tag) {
        return tagMapper.insert(tag);
    }

    @Override
    public Tag findById(int id) {
        return tagMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(Tag tag) {
        return tagMapper.updateByPrimaryKeySelective(tag);
    }

    @Override
    public int delete(int id) {
        return tagMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int count() {
        return tagMapper.count();
    }
}
